package com.gmail.hongyz.myfuse.dao.impl;

import java.util.List;

import com.gmail.hongyz.myfuse.common.PageObject;
import com.gmail.hongyz.myfuse.dao.ProjectDao;
import com.gmail.hongyz.myfuse.model.Project;
import com.gmail.hongyz.myfuse.model.UserRole;

public class ProjectDaoImpl extends BaseDaoImpl implements ProjectDao {

	public Project getProject(String id) {
		Project Project = (Project)getHibernateTemplate().get(Project.class, id);
		return Project;
	}

	public void removeProject(String id) {
		getHibernateTemplate().delete(getProject(id));
	}

	public void saveProject(Project Project) {
		getHibernateTemplate().saveOrUpdate(Project);
//		getHibernateTemplate().flush();
	}
	
	public List<Project> getProjects(PageObject pageObject) {
		return queryForPage("from Project", pageObject);
	}

	public List<UserRole> getUserRoles(String projectId) {
		return getHibernateTemplate().find("from UserRole where projectId=?", projectId);
	}

}
